package com.aaa.util;

import com.aaa.entity.Result;
import org.apache.shiro.authz.UnauthorizedException;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * @author ：SakuraLi
 * @date ：Created in 2020/12/2 14:11
 * @description：  全局异常配置
 * @modified By：
 * @version: 1.0
 */

@ControllerAdvice
public class GlobalHandlerException extends Throwable {


    @ExceptionHandler(Exception.class)
    @ResponseBody
    public Result handlerException(Exception e){
        e.printStackTrace();
        return new Result(88888,"程序员正在送外卖",null);
    }
    @ExceptionHandler(UnauthorizedException.class)
    @ResponseBody
    public Result UnauthorizedException(Exception e){
        e.printStackTrace();
        return new Result(66666,"你不配！",null);
    }

}
